//app.js

const openidUrl = require('./config').openid;
const mod = require('/utils/util.js');

App({
  onLaunch: function () {

  },

  getOpenid : function(){
    var that = this;
    return new Promise(function (resolve, reject){

      wx.login({
        success: function (res) {
          //code 获取用户信息的凭证
          if (res.code) {
            //请求获取用户详细信息
            mod.postData(openidUrl, {
              code: res.code
            }, function (res) {
              
              wx.setStorageSync('usercode', res.data.data);
              
              var res = {
                status: 200,
                data: res.data.data
              }
              resolve(res);

            })

          } else {
            console.log('获取用户登录态失败！' + res.errMsg)
            reject('error'); 
          }
        }
      }) 

    })
  },




  globalData: {

    comment : null,
    formid : ''

  }
})